package org.game.alg;

import java.util.Random;

import org.game.controll.GWPlayerController;
import org.game.map.GWMap;
import org.game.obj.unit.GWUnit;
import org.game.player.GWPlayer;

public class Algorithm1 extends GWPlayerController {

	public Algorithm1(GWMap map, GWPlayer player) {
		super(map, player);
	}

	@Override
	public void createAction() {
		int r = new Random().nextInt(3);
		switch(r) {
		case 0:
			addUnit(PEASANT);
			break;
		case 1:
			addUnit(SPEARMAN);
			break;
		case 2:
			addUnit(KNIGHT);
			break;
		}
	}

	@Override
	public void moveAction(int i) {
		GWUnit unit = getPlayer().getUnit(i);
		if(unit != null) {
			moveUnit(unit.getNumber(), new Random().nextInt(9)+1);
		}
	}

	@Override
	public void gatherResourcesAction(int i) {
		GWUnit unit = getPlayer().getUnit(i);
		if(unit != null) {
			gatherResources(unit.getNumber(), new Random().nextInt(9)+1);
		}
	}

	@Override
	public void bringResourcesAction(int i) {
		GWUnit unit = getPlayer().getUnit(i);
		if(unit != null) {
			bringResources(unit.getNumber(), new Random().nextInt(9)+1);
		}
	}

	@Override
	public void attackAction(int i) {
		GWUnit unit = getPlayer().getUnit(i);
		if(unit != null) {
			attackEnemy(unit.getNumber(), new Random().nextInt(9)+1);
		}
	}

	
}
